//重置
function reset(){
	$("#username").val("");
	$("#password").val("");
}
//登录
function login(){
	var username = $("#username").val();
	var password = $("#password").val();
	if("" == username || ""== password){
		$.messager.alert("操作提示", "用户名和密码不能为空！",'info');  
		return;
	}else{
		addCookie("username",username,1,"/");
		$.ajax({
			url:$WEB_ROOT_PATH+"/Login/login.json",
			type:"post",
			data: JSON.stringify({"username":username,"password":password}),
			contentType: "application/json",
			dataType:"json",
			success:function(result){
				if(result.data.success == '0'){
					if(result.data.roleId == '1'){
						window.location.href=$WEB_ROOT_PATH+"/jsp/index/indexTemplate.jsp";//登录成功
					}else{
						window.location.href=$WEB_ROOT_PATH+"/jsp/index/customerIndex.jsp";//登录成功
					}
					
				}else{
					$.messager.alert("操作提示", "用户名或密码错误！",'info');
					return;
				}
			}
		})
	}
}

function keyDown(e) {
	  var ev= window.event||e;
	  //13是键盘上面固定的回车键
	  if (ev.keyCode == 13) {
		  login();
	  }
}